package com.zhang.network.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhang.network.model.Friend;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zhang
 * @since 2021-04-03
 */
public interface FriendMapper extends BaseMapper<Friend> {

    @Select("SELECT count(*) as sameFriendNum FROM ( " +
            "SELECT * from friend where user_id = #{userId} and status = 1 " +
            ") t1 " +
            "INNER JOIN ( " +
            "SELECT * from friend where user_id = #{queryId} and status = 1 " +
            ") t2 " +
            "ON t1.friend_id = t2.friend_id")
    int sameFriendNum(Integer userId, Integer queryId);

}
